<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fns.tld" prefix="fns" %>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/head.jsp" />
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/demo.css" rel="stylesheet"/>
    <link href="${basePath}/resources/zheng-admin/plugins/zTree_v3/css/metroStyle/metroStyle.css" rel="stylesheet"/>
</head>
<body>

<form class="layui-form layui-form-pane" id="_form">
    <input value="${plan.id}" type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">计划名称</label>
        <div class="layui-input-block">
            <input type="text" name="planName" lay-verify="required" autocomplete="off" placeholder="请输入个人日计划名称"
                   class="layui-input" value="${plan.planName}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计划日期</label>
        <div class="layui-input-block">
            <input type="text" name="planDate" autocomplete="off"
                   class="layui-input date-select" readonly="readonly">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计划详情</label>
        <div class="layui-input-block">
            <textarea id="planDetail" name="planDetail" style="display: none;">${plan.planDetail}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="remark" autocomplete="off" placeholder="请输入备注"
                      class="layui-textarea">${plan.remark}</textarea>
        </div>
    </div>
    <%--todo 上传组件--%>
    <div class="layui-form-item" style="float: right">
        <button class="layui-btn layui-btn-danger" type="button" onclick="deletePlan()">删除</button>
        <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
    </div>
</form>
<jsp:include page="/resources/inc/pageFooter.jsp" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.js"></script>
<script>
    var layedit;
    var editIndex;
    var planId = ${plan.id};
    $(function () {
        layui.use(['laydate', 'layedit'], function () {
            layedit = layui.layedit;
            editIndex = layedit.build('planDetail', {
                tool: [
                    'strong' //加粗
                    , 'italic' //斜体
                    , 'underline' //下划线
                    , 'del' //删除线
                    , '|' //分割线
                    , 'left' //左对齐
                    , 'center' //居中对齐
                    , 'right' //右对齐
                    , 'link' //超链接
                    , 'unlink' //清除链接
                    , 'face' //表情

                ]
            }); //建立编辑器
            laydate = layui.laydate;
            $(".date-select").each(function (index, input) {
                laydate.render({
                    elem: this //指定元素
                    , theme: '#393D49'
                    , type: 'date'
                    , value: new Date("${plan.planDate}")
                });
            });
        });
        //提交方法
        FormCommon.initForm({
            url: "${basePath}/oa/wc/personalDayPlan/update",
            subContentType: "json",
            editData: function (data) {
                data.planDetail = layedit.getContent(editIndex);
                return data;
            },
            afterCommit: function (res) {
                if (!parent.$table) {
                    parent.refresh();
                } else {
                    parent.$table.bootstrapTable('refresh');
                }
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            }
        });
    });
    function deletePlan() {
        $.ajax({
            url: '${basePath}/oa/wc/personalDayPlan/delete/' + planId,
            type: "get",
            success: function (res) {
                if (!parent.$table) {
                    parent.refresh();
                } else {
                    parent.$table.bootstrapTable('refresh');
                }
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
                parent.layer.msg("操作成功！", {
                    icon: 1,
                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                });
            }, error: function (res) {
                parent.layer.msg("删除失败！", {
                    icon: 5,
                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        })
    }
</script>
</body>
</html>
